package cn.hfatec.shms.web.qz.qzByl.service;

import java.util.List;
import java.util.HashMap;


import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.hfatec.base.BaseDao;
import cn.hfatec.Page;
import cn.hfatec.Table;
import cn.hfatec.shms.web.qz.qzByl.model.QzByl;
import cn.hfatec.shms.web.qz.qzByl.dao.QzBylDao;
import cn.hfatec.shms.web.qz.qzByl.model.QzBylParams;

import javax.annotation.Resource;



/**
 *
 * @author hfatec
 * @version 1.0
 *
 * the JAVA code is generate by middlegen
 *
 */
@Service("QzBylService")
public class QzBylService {

    public static final String BEAN_ID = "QzBylService";

    //注入Dao层
    @Resource(name = "QzBylDao")
    private QzBylDao qzBylDao;

    //注入BaseDao
    @Resource(name = "BaseDao")
    private BaseDao baseDao;

    /**
     *
     * 查询数据
     *
     * @param qzBylParams
     * @param page
     *
     */
    @Transactional
    public Table queryQzBylTable(QzBylParams qzBylParams, Page page){

        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("params", qzBylParams);
        return baseDao.queryTableByPage("queryQzByl", params, page);
    }
    /**
     *
     * 根据ID获取数据
     * @param qzBylParams
     *
     */
    @Transactional
    public List qzBylHz(QzBylParams qzBylParams) {

        return qzBylDao.queryQzBylHz(qzBylParams);
    }

    @Transactional
    public List qzBylDif(QzBylParams qzBylParams) {

        return qzBylDao.queryQzBylDif(qzBylParams);
    }

    /**
     *
     *
     *
     */
    @Transactional
    public List qzLine( ) {

        return qzBylDao.queryQzLine();
    }




    /**
     *
     * 插入数据
     * @param qzByl
     *
     */
    @Transactional
    public void saveQzByl(QzByl qzByl) {
        if(qzByl.getId() != null) {
            QzByl result = getQzByl(qzByl.getId());
            if(result != null) {
                qzBylDao.update(qzByl);
            } else {
                qzBylDao.insert(qzByl);
            }
        } else {
            qzBylDao.insert(qzByl);
        }
    }

    /**
     *
     * 删除数据
     * @param id
     *
     */
    @Transactional
    public void deleteQzByl(Integer id) {

        qzBylDao.delete(id);
    }

    /**
     *
     * 删除数据
     * @param qzBylList
     *
     */
    @Transactional
    public void deleteQzBylBatch(List<String> qzBylList) {
        for(String id : qzBylList) {
            deleteQzByl(Integer.valueOf(id));
        }
    }

    /**
     *
     * 根据ID获取数据
     * @param id
     *
     */
    @Transactional
    public QzByl getQzByl(Integer id) {

        return qzBylDao.getQzBylById(id);
    }


}